package com.project.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.bean.RoleBean;
import com.project.service.IRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("role")
public class RoleController {
    @Autowired
    private IRoleService service;
    @RequestMapping("findAll")
    public List<RoleBean>findAll(){
        return service.findAll();
    }

    @RequestMapping("cutAll")
    public IPage<RoleBean> cutAll(int pageNO){
        return  service.cutAll(pageNO);
    }

    @RequestMapping("add")
    public  String  add(RoleBean role,int [] gradeArray){
        service.add(role,gradeArray);

        return "ok";
    }

@RequestMapping("findById")
    public  RoleBean findById(int id){
        return service.findById(id);
    }


    @RequestMapping("update")
    public String  update(int id,int [] gradeArray){
        service.updateGrade(id,gradeArray);
        return "ok";
    }
@RequestMapping("del")
    public  String  del(int id){
        service.del(id);
        return "ok";
    }
}
